%macro get_f1099div;


	proc printto new log = "&logdir./get_f1099div.txt";
	run;


	/****************************************************
	*			Put individuals into a tinlist			*
	****************************************************/
	%make_tinlist;


	

			options errors = 0;
				proc sql noprint;
				[connection details redacted]
					create table sample as
					select * from connection to iq 
					(
					select 
						a.[redacted] as person_id,
						a.[redacted] as div_ord,
						a.[redacted] as f1099div_cg,
						a.[redacted] as div_qlfy,
						a.[redacted] as wh,
						a.[redacted] as div_199a
					from [redacted] as a
						inner join #tinlist as b
							on(a.[redacted] = b.person_id)
					where a.[redacted] = &base_yr
						and a.[redacted]<=4
					);
				disconnect from iq;
				quit;



		/****************************
		*		Take a proc sum		*
		****************************/
		proc means data = sample nway noprint;
			class person_id;
			output out = rlib.f1099div(drop=_type_ _freq_)
				sum(div_ord f1099div_cg div_qlfy wh div_199a) = 
					div_ord f1099div_cg div_qlfy f1099div_wh div_199a;
	

	proc printto;
	run;

	


%mend;
